var hash = window.location.hash.slice(1);
var groupId = hash.split(",")[0];
var queryGroupId =groupId;
var queryOrgId = hash.split(",")[1];
var queryGroupName ="";
var queryTopicTitle ="";
var pageSize = 8;
var pSize = 8;
var queryCount = 0;
var word_w = "500px";
var word_h = "700px";
var startUrl = "";
var temps =[];//视频数组
var copyCardId = "";
var removeflag ="";//是否移除自身
var windowflag = true;//用于滚动加载
var delCardId = "";
var moveTopicId ="";//移动的card所在主题
var copyTitle="";//复制分享修改的标题
//groupInfo(groupId);
findActivity(groupId);
function uploadBtn(){
	$("#file").click();
}
function uploadPostBtn(){
	$("#postFile").click();
}
function uploadShowPostBtn(){
	$("#postShowFile").click();
}
function uploadRePostBtn(){
	$("#rePostFile").click();
}
function uploadPostRePostBtn(){
	$("#postRePostFile").click();
}
$(function(){
	
	$(window).scroll(function(){
		var viewH =$(this).height();//可见高度
	    var contentH =$(document).height();//内容高度
	    var scrollTop =$(this).scrollTop();//滚动高度
	    if(scrollTop/(contentH -viewH)>=0.95){ //到达底部100px时,加载新内容
	      // 这里加载数据..
    	  if(windowflag&&pSize<queryCount){
    		  windowflag =false;
    		  pSize+=8;
    		  findActivity(groupId);
		  }
	    }
	});
	
	/*复制分享卡片开始*/
	$('#copyModal').on('hidden.bs.modal', function () {
		  $("#copyQueryName").val("");
		  queryGroupName="";
		  pageSize=8;
	});
	$("#msgModal").on('hidden.bs.modal',function(){
		//刷新
		//location.reload();
	})
	$('#copyCardModal').on('hidden.bs.modal', function () {
		  $("#copyCardQueryName").val("");
		  $("#queryTopicName").val("");
		  queryGroupName="";
		  queryTopicTitle = "";
		  copyCardId="";
		  removeflag="";
		  moveTopicId="";
		  pageSize=8;
		  $('#copyCardModal').find(".copy-card").show();
		  $('#copyCardModal').find(".move-card").hide();
	});
	$("#queryTopicName").keyup(function(){
		queryTopicTitle = $(this).val();
		cardTopicList(groupId,removeflag);
	})
	$("#queryTopicPostName").keyup(function(){
		queryTopicTitle = $(this).val();
		postTopicList(groupId,removeflag);
	})
	/*复制分享卡片结束*/
	
	//查询视频路径配置
	$.ajax({
		url:"../../../learn/card/findFlashStart.json",
		success:function(data){
			startUrl = data.data;
		}
	});
	$(".uploadBtn").click(function() {
		$("#groupfile").click();
	});
	$('#cardViewModal').on('hidden.bs.modal', function () {
		// 执行一些动作...
		for(var i = 0;i<temps.length;i++){
			videojs(temps[i]).dispose();
		}
		temps=[];
	})
	postEdit();
	$('#cardViewModal').modal('hide');
	/**
	 * 组设置
	 */
	/*$(".groupImg .glyphicon").click(function(){
		$(".groupMenu").slideDown(1000);
	});
	$(".groupMenu .item").click(function(){
		var text = this.innerHTML;
		$(".groupMenu").slideUp(1000);
	});*/
	/**
	 * 筛选
	 */
	$(".selFilter").click(function(){
		$(".filterList").slideDown(1000);
	});
	$(".sortItem .filterIco").click(function(){
		$(".filterList").slideDown(1000);
	});
	$(".filterList .item").click(function(){
		var text = this.innerHTML;
		$(".selFilter")[0].innerHTML=text;
		$(".filterList").slideUp(1000);
	});
	/**
	 * card设置
	 */
	$(".cardInfo .glyphicon").click(function(){
		$(this).next().slideDown(1000);
	});
	$(".cardOperating .item").click(function(){
		var text = this.innerHTML;
		$(this).parent().slideUp(1000);
	});
	
});
function groupInfo(groupId){
	$.get('../../../hivelearn/group/findGroup.json?id=' + groupId, function(datas) {
		if (datas.success) {
			var time = new Date(datas.data.createDate);
			var year = time.getFullYear();
			var month = (time.getMonth() + 1) > 9 ? (time.getMonth() + 1) : '0' + (time.getMonth() + 1);
			datas.data.createDate = '（' + year + '年' + month + '月）';
			
			var dom = _.template($('#groupInfoTpl').html());
			dom = dom(datas.data);
			$("#groupInfo").html(dom);
		}
	})
}
function toShareLearning(){
	window.location.href="../../../hivelearnweb/portal/meetingList/meetingList.html#"+queryOrgId;
};
//复制
function copyPost(id){
	$("#copyPostModal").find(".right-content-list").show();
	$("#copyPostModal").find(".right-content-edit").hide();
	copyPostId = id;
	$("#copyPostModal").find(".topicImg").empty();
	$("#copyPostModal").find(".topicTitle").text("");
	$("#copyPostModal").find(".topicTitle").attr("title","");
	$("#copyPostModal").find(".title").text("复制");
	$("#copyPostModal").find(".right-top").text("你想复制到哪里？");
	$.ajax({
		url:'../../../hivelearn/hivelearnpost/findHiveLearnPost.json?id=' + id + '&groupId=' + groupId,
		success:function(data){
			copyTitle=data.data.postContent;
			$("#copyPostModal").find(".topicTitle").text(data.data.postContent);
			$("#copyPostModal").find(".topicTitle").attr("title",data.data.postContent);
			groupList(groupId,"");
			$("#copyQueryPostName").unbind("keyup");
			$("#copyQueryPostName").keyup(function(){
				queryGroupName = $(this).val();
				groupList(groupId,"");
			})
			$('#copyPostModal').modal('show');
		}
	})
}
//群组列表查询
function groupList(groupId,noGroupId) {
	$.get('../../../hivelearn/group/findCopyGroupList.json?queryOrgId='+queryOrgId+"&pageSize="+pageSize
			+"&queryGroupName="+queryGroupName+"&queryGroupId="+groupId+"&queryNoGroupId="+noGroupId, function(datas) {
		if (datas.success) {
			var dom = _.template($('#groupTpl').html());
			
			var count = datas.data.count;
			dom = dom(datas.data);
			$("#groupPostlist").html(dom);
			//滚动加载
			$("#copyPostModal").find(".right-list").scroll(function () {  
                var $this = $(this),  
                viewH = $(this).height(),//可见高度  
                contentH = $(this).get(0).scrollHeight,//内容高度  
                scrollTop = $(this).scrollTop();//滚动高度  
                //if(contentH - viewH - scrollTop <= 100) { //到达底部100px时,加载新内容  
                if (scrollTop / (contentH - viewH) >= 0.98&&count>pageSize) { //到达底部100px时,加载新内容  
                    //console.log("scrollTop："+scrollTop+",contentH："+contentH+",viewH："+viewH);  
                    pageSize+=5;
                    groupList(groupId,noGroupId);
                }  
            }); 
		}
	})
}
//群组主题列表查询（post）
function postTopicList(id,flag) {
	pageSize=8;
	removeflag = flag;
	$.get("../../../hivelearn/topic/findTopicList.json?pageSize="+pageSize
			+"&queryTopicTitle="+queryTopicTitle+"&queryGroupId="+id+"&groupId="+id, function(datas) {
		if (datas.success) {
			var dom;
			dom = _.template($('#postGroupTpl').html());
			
			if(flag){
				datas.data.topicQuery.moveflag = 1;
				for(var i=0;i<datas.data.topicQuery.resultList.length;i++){
					if(moveTopicId==datas.data.topicQuery.resultList[i].topicId){
						datas.data.topicQuery.resultList[i].flag = 1;//用于移动card时，不能移动到自己下
					}
				}
			}else{
				datas.data.topicQuery.moveflag=0;
			}
			var count = datas.data.topicQuery.count;
			dom = dom(datas.data.topicQuery);
			$("#topicPostlist").html(dom);
			$("#copyPostModal").find(".right-content-list").hide();
			$("#copyPostModal").find(".right-content-edit").show();
			//返回
			$("#copyPostModal").find(".share-btn").find(".arrow").click(function(){
				$("#copyPostModal").find(".right-content-list").show();
				$("#copyPostModal").find(".right-content-edit").hide();
			});
			//滚动加载
			$("#copyPostModal").find(".right-content-edit").find(".right-list").scroll(function () {  
				var $this = $(this),  
				viewH = $(this).height(),//可见高度  
				contentH = $(this).get(0).scrollHeight,//内容高度  
				scrollTop = $(this).scrollTop();//滚动高度  
				//if(contentH - viewH - scrollTop <= 100) { //到达底部100px时,加载新内容  
				if (scrollTop / (contentH - viewH) >= 0.98&&count>pageSize) { //到达底部100px时,加载新内容  
					//console.log("scrollTop："+scrollTop+",contentH："+contentH+",viewH："+viewH);  
					pageSize+=5;
					cardGroupList(id);
				}  
			}); 
		}
	})
}
function saveCopyPost(id){
	$.ajax({
		url:"../../../hivelearn/hivelearnpost/copyPost.json",
		data:{"groupId":queryGroupId,"topicId":id,"postId":copyPostId,"copyTitle":copyTitle},
		success:function(data){
			$('#copyPostModal').modal('hide');
			copyPostId="";
			$("#msgModal").find(".msg").text("保存成功");
			$("#msgModal").modal("show");
			findActivity(queryGroupId);
		}
	});
}
//修改复制，分享标题
function toUpdatePostTitle(e){
	$(e).hide();
	var $title = $(e).siblings(".topicTitle");
	var title= $title.text();
	$title.empty();
	$title.append("<input type='text' class='updateCopyPostTitle' maxlength='40' value='"+title+"'/>");
	$title.find(".updateCopyPostTitle").focus();
	$title.find(".updateCopyPostTitle").blur(function(){
		var $val = $(this).val();
		if($val){
			copyTitle=$val;
		}
		$title.empty();
		$title.text(copyTitle);
		$(e).show();
	})
}
function findActivity(groupId){
	$.get('../../../hivelearn/hivelearnactivity/findHiveLearnActivityList.json?queryGroupId=' + groupId+'&groupId='+groupId+"&pageSize="+pSize, function(datas) {
		if (datas.success) {
			for(var j = 0;j<datas.data.resultList.length;j++){
				for(var i = 0; i<datas.data.resultList[j].dtoList.length;i++){
					var time = new Date(datas.data.resultList[j].dtoList[i].postTime);
					var year = time.getFullYear();
					var month = (time.getMonth() + 1) > 9 ? (time.getMonth() + 1) : '0' + (time.getMonth() + 1);
					var day = time.getDate();
					datas.data.resultList[j].dtoList[i].postTime = year + '-' + month + '-' + day;
				}
			}
			queryCount=datas.data.query.count;
			var dom = _.template($('#activeInfoTpl').html());
			dom = dom(datas.data);
			$("#activeInfo").html(dom);
			windowflag = true;
			isShow();
		}
	})
}
function showMyself(){
	$("#cardView").find(".myself").each(function(){
		//$(this).remove
		$(this).removeClass("postdelete").show();
		$(this).closest(".hideColumn").removeClass("hideColumn").show();
	})
	$("#postView").find(".myself").each(function(){
		//$(this).remove
		$(this).removeClass("postdelete").show();
		$(this).closest(".hideColumn").removeClass("hideColumn").show();
	})
}
function fabulous(id,type,code,page,cardId,ispost){
	$.get('../../../hivelearn/praise/addOrDelPraise.json?objectId='+id+'&objectType='+type+'&code='+code+'&groupId='+groupId, function(datas) {
		if (datas.success) {
			//groupInfo(groupId);
			findActivity(groupId);
			if(page==1 && ispost !=2){
				showPostInfo(id,1);
			}
			if(page==1 && ispost ==2){
				showPostInfo(cardId,1);
			}
			if(page==2){
				showCardInfo(id,1);
			}
			if(page==3){
				showCardInfo(cardId,1);
			}
		}
	})
}

function postEdit(){
	$.get('../../../hivelearn/hivelearnactivity/findHiveLearnActivityList.json?queryGroupId=' + groupId+'&groupId='+groupId, function(datas) {
		if (datas.success) {
			var dom = _.template($('#editInfoDivTpl').html());
			dom = dom(datas.data);
			$("#editInfoDiv").html(dom);
			$("#picPostView").hide();
		}
	})
}
//card详情
var currentCardId;
function showCardInfo(id,type){
	if(clickCheck()){
	currentCardId=id;
	$.get('../../../hivelearn/cardtext/findCardTextList.json?queryCardId=' + id+'&groupId='+groupId, function(datas) {
		if (datas.success) {
			var dom = _.template($('#cardViewTpl').html());
			datas.data.startUrl = startUrl;
			dom = dom(datas.data);
			$("#cardView").html(dom);
			
			$("#picCardView").hide();
			
			//加载内容
			showKeyPoint(id);
			if(type && type == 1){
				showCardInfo2(id,1);
			}else{
				showCardInfo2(id);
			}
			showReply(id);
			var height = $(window).height();
			$(".cardViewShow").css("max-height",height*0.8+"px");
			initSlide();
//			$('.slideWrap').css("margin-left","-46px");
			for(var i =0;i<datas.data.resultList.length;i++){
				var d = datas.data.resultList[i];
				if(d.playUrl){
					//videojs("my-video-"+d.cardTextId).dispose();
					/*if(temps.indexOf(d.cardTextId)==-1){
						videojs("my-video-"+d.cardTextId);
						temps.push(d.cardTextId);
					}else{
						videojs("my-video-"+d.cardTextId).dispose();
						videojs("my-video-"+d.cardTextId);
					}*/
					videojs("my-video-"+d.cardTextId);
					temps.push("my-video-"+d.cardTextId);
				}
			}
		}
	})
	$('#cardViewModal').modal('show');
	}
}
//card详情点赞

//toTopicDetails 前往主题详情
function toTopicDetails(id){
	window.location.href="../studyTalk/studyTalk.html#"+id+","+queryGroupId+","+queryOrgId+","+1;
}

//topic详情
function showTopicInfo(id){
	if(clickCheck()){
	$.get('../../../hivelearn/hivelearnactivity/findHiveLearnActivity.json?id=' + id+'&groupId='+groupId, function(datas) {
		if (datas.success) {
			for(var i = 0;i<datas.data.cardList.length;i++){
				var d = datas.data.cardList[i];
				if(d.cardTitle.length>20){
					d.cTitle = d.cardTitle.substring(0,20)+"...";
				}else{
					d.cTitle = d.cardTitle;
				}
			}
			
			var dom = _.template($('#topicViewTpl').html());
			dom = dom(datas.data);
			$("#topicView").html(dom);

			var height = $(window).height();
			$(".topicViewShow").css("max-height",height*0.8+"px");
		}
	})
	$('#topicViewModal').modal('show');
	}
}
//topic详情-card跳转
function cardView(cardId,activeId){
	window.location.href="../studyTalkEdit/studyTalkEdit.html#"+cardId+","+groupId+","+activeId+","+queryOrgId;
}
//topic详情-删除
function deleteCard(id,topicId){
	//alert(topicId);
	$.get('../../../hivelearn/card/deleteCardByIds.json?id=' + id+'&groupId='+groupId, function(datas) {
		if (datas.success) {
			$("#msgModal").find(".msg").text("删除成功！");
			$("#msgModal").modal("show");
			target.value = "";
			
			showTopicInfo(topicId);
		}
	})
}
//post详情
var currentPostId;
function showPostInfo(id,code){
	if(code==1){
		if(clickCheck()){//点击冒泡判断
			currentPostId = id;
			$.get('../../../hivelearn/hivelearnactivity/findHiveLearnActivity.json?id=' + id+'&groupId='+groupId, function(datas) {
				if (datas.success) {
					var dom = _.template($('#postViewTpl').html());
					dom = dom(datas.data);
					$("#postView").html(dom);
		
					$("#picShowPostView").hide();
					$("#editPost").hide();
					$("#noEditPost").show();
					
					var height = $(window).height();
					$(".postViewShow").css("max-height",height*0.8+"px");
					
					$(".postReHuiFu").each(function(){
						$(".picShowRePostView").hide();
						$(this).hide();
					});
					isShow(showMyself);
				}
			})
			$('#postViewModal').modal('show');
		}
	}else if(code==2){
		currentPostId = id;
		$.get('../../../hivelearn/hivelearnactivity/findHiveLearnActivity.json?id=' + id+'&groupId='+groupId, function(datas) {
			if (datas.success) {
				var dom = _.template($('#postViewTpl').html());
				dom = dom(datas.data);
				$("#postView").html(dom);
	
				$("#picShowPostView").hide();
				$("#editPost").show();
				$("#noEditPost").hide();
				
				var height = $(window).height();
				$(".postViewShow").css("max-height",height*0.8+"px");
				
				$(".postReHuiFu").each(function(){
					$(".picShowRePostView").hide();
					$(this).hide();
				});
				isShow(showMyself);
			}
		})
		$('#postViewModal').modal('show');
	}
}

//post编辑
function yesEditPost(){
	$("#editPost").show();
	$("#noEditPost").hide();
}
function noEditPost(){
	$("#editPost").hide();
	$("#noEditPost").show();
}
function editPost(id){
	var editPosts = $("#editPosts").text();
	if(editPosts==null||editPosts==""){
		$('#notNullModal').modal('show');
		return false;
	}
	if(editPosts.length>=100){
		$('#notMaxModal').modal('show');
		return false;
	}
	$.get('../../../hivelearn/hivelearnpost/saveOrUpdateHiveLearnPost.json?editPosts='+editPosts+'&postId='+id+'&groupId='+groupId, function(datas) {
		if (datas.success) {
			showPostInfo(id,1);
			findActivity(groupId);
		}
	})
}

//信息
function showCardInfo2(id,type){
	$.get('../../../hivelearn/card/findCard.json?id=' + id+'&groupId='+groupId+'&type='+type, function(datas) {
		if (datas.success) {
			$(".st-title").text(datas.data.cardTitle);
			$(".st-author").text(datas.data.userName);
			$(".st-time").text(datas.data.createDateStr);
			$(".cardDzNum").text(datas.data.numVisits);
			$(".cardFwNum").text(datas.data.numReply);
		}
	})
}
//关键点
function showKeyPoint(id){
	$.get('../../../learn/keypoint/findKeyPointList.json?queryCardId=' + id+'&groupId='+groupId, function(datas) {
		if (datas.success) {
			$(".st-gjdnum").text(datas.data.resultList.length);
		}
	})
}
//回复\
function showReply(id){
	$.get('../../../hivelearn/hivelearnactivity/findHiveLearnActivity.json?id=' + id+'&groupId='+groupId, function(datas) {
		if (datas.success) {
			var text = "评论（"+datas.data.replyNum+"）";
			$(".st-plnum").text(text);
			var dom = _.template($('#replyShowTpl').html());
			dom = dom(datas.data);
			$("#replyShow").html(dom);
			
			$(".postHuiFu").each(function(){
				$(this).hide();
//				$(this).click()
			});
			isShow(showMyself);
		}
	})
}
function deletePost(id){
	$.get('../../../hivelearn/hivelearnactivity/deletePost.json?id=' + id+'&groupId='+groupId, function(datas) {
		if (datas.success) {
			findActivity(groupId);
			location.reload();
		}
	})
}
function deleteRePost(id,code){
	$.get('../../../hivelearn/hivelearnpost/deleteReplyPostByIds.json?ids=' + id+'&groupId='+groupId+'&code='+code+'&cardId='+currentCardId, function(datas) {
		if (datas.success) {
			findActivity(groupId);
			showPostInfo(currentPostId,1);
		}
	})
}
//删除卡片中回复
function deleteCardReply(id,code,type){
	$.get('../../../hivelearn/hivelearnpost/deleteReplyByIds.json?ids=' + id+'&groupId='+groupId+'&code='+code+'&cardId='+currentCardId+'&type='+type, function(datas) {
		if (datas.success) {
			findActivity(groupId);
			showCardInfo(currentCardId,1);
		}
	})
}

//删除帖子中回复
function deletePostReply(id,code,type,pId){
	$.get('../../../hivelearn/hivelearnpost/deleteReplyByIds.json?ids=' + id+'&groupId='+groupId+'&code='+code+'&cardId='+currentPostId+'&pId='+pId+'&type='+type, function(datas) {
		if (datas.success) {
			findActivity(groupId);
			showPostInfo(currentPostId,1);
		}
	})
}
var flag = true;
var cpId;
function zhanKai(id){
	if(flag){
		$(".reCardHide").hide();
		$("."+id).show();
		flag = false;
	}else{
		$(".reCardHide").hide();
		$("."+id).hide();
		flag = true;
	}
	cpId = id;
	$(".picShowReCardView"+id).hide();
//	$(".picShowRePostView"+id).hide();
}
function submitReply(id,code){
	var postContent = $("#st-liuyan").val();
	var attachId = $("#topicCover").val();
	if(postContent==null||postContent==""){
		$('#notNullModal').modal('show');
//		$("#msgModal").find(".msg").text("回复内容不能为空！");
//		$("#msgModal").modal("show");
		return false;
	}
	if(postContent.length>=100){
		$('#notMaxModal').modal('show');
//		$("#msgModal").find(".msg").text("回复内容不得超过100个字！");
//		$("#msgModal").modal("show");
		return false;
	}
	var pattern = new RegExp("[`@#$^&*]");
	if(pattern.test(postContent)){
		$('#notTeShuModal').modal('show');
	    return false;
	}
	$.get(encodeURI('../../../hivelearn/hivelearnpost/replyPost.json?parentId=' + id+'&attachId='+attachId+'&postContent='+postContent+'&code='+code+'&groupId='+groupId+'&activeId='+id), function(datas) {
		if (datas.success) {
			findActivity(groupId);
			showCardInfo(id,1);
		}
	})
}
function submitPostReply(id,code){
	var postContent = $("#st-postLiuyan").val();
	var attachId = $("#postShowCover").val();
	if(postContent==null||postContent==""){
		$('#notNullModal').modal('show');
		return false;
	}
	if(postContent.length>=100){
		$('#notMaxModal').modal('show');
		return false;
	}
	var pattern = new RegExp("[`@#$^&*]");
	if(pattern.test(postContent)){
		$('#notTeShuModal').modal('show');
	    return false;
	}
	$.get(encodeURI('../../../hivelearn/hivelearnpost/replyPost.json?parentId=' + id+'&attachId='+attachId+'&postContent='+postContent+'&code='+code+'&groupId='+groupId+'&type='+1), function(datas) {
		if (datas.success) {
			findActivity(groupId);
			showPostInfo(id,1);
		}
	})
}
function submitRePost(id,code,activeId){
	var postContent = $("#rePostInput"+id).val();
	var attachId = $("#RePostCover").val();
	if(postContent==null||postContent==""){
		$('#notNullModal').modal('show');
		return false;
	}
	if(postContent.length>=100){
		$('#notMaxModal').modal('show');
		return false;
	}
	var pattern = new RegExp("[`@#$^&*]");
	if(pattern.test(postContent)){
		$('#notTeShuModal').modal('show');
	    return false;
	}
	$.get(encodeURI('../../../hivelearn/hivelearnpost/replyPost.json?parentId=' + id+'&attachId='+attachId+'&postContent='+postContent+'&code='+code+'&groupId='+groupId+'&type='+2+'&activeId='+activeId), function(datas) {
		if (datas.success) {
			findActivity(groupId);
			showCardInfo(activeId,1);
		}
	})
}
function submitPostRePost(id,code,activeId){
	var postContent = $("#postRePostInput"+id).val();
	var attachId = $("#postRePostCover").val();
	if(postContent==null||postContent==""){
		$('#notNullModal').modal('show');
		return false;
	}
	if(postContent.length>=100){
		$('#notMaxModal').modal('show');
		return false;
	}
	var pattern = new RegExp("[`@#$^&*]");
	if(pattern.test(postContent)){
		$('#notTeShuModal').modal('show');
	    return false;
	}
	$.get(encodeURI('../../../hivelearn/hivelearnpost/replyPost.json?parentId=' + id+'&attachId='+attachId+'&postContent='+postContent+'&code='+code+'&groupId='+groupId+'&type='+2+'&activeId='+activeId), function(datas) {
		if (datas.success) {
			findActivity(groupId);
			showPostInfo(activeId,1);
		}
	})
}
function liuYan(){
	document.getElementById("liuYan").scrollIntoView();
}
function postBtn(code){
	var editText = $("#editText").text();
	var attachId = $("#postCover").val();
	if(editText==null || editText==""){
		$("#msgModal").find(".msg").text("帖子内容不能为空！");
		$("#msgModal").modal("show");
		return false;
	}
	var pattern = new RegExp("[`@#$^&*]");
	if(pattern.test(editText)){
		$("#msgModal").find(".msg").text("帖子内容不能包含特殊字符！");
		$("#msgModal").modal("show");
	    return false;
	}
	$.get(encodeURI('../../../hivelearn/hivelearnpost/saveOrUpdateHiveLearnPost.json?parentId=' + groupId+'&attachId='+attachId+'&postContent='+editText+'&code='+code+'&groupId='+groupId), function(datas) {
		if (datas.success) {
			//groupInfo(groupId);
			findActivity(groupId);
			postEdit();
		}
	})
}

function uploadFile(e) {
	/*if ($("#file").val()&&checkfileAtt(e)) {
		$.ajax({
			url : "../../../hivelearn/topic/uploadFileImage.json",
			data : new FormData($('#uploadForm')[0]),
			method : "post",
			processData : false,
			contentType : false,
			cache : false,
			success : function(data){ // 服务器成功响应处理函数
				$('[name="topicCover"]').val(data.data.attachid);
				console.log("上传成功");
				
				$("#picCardView").show();
				var type = data.data.attachextname;
				if(type=="jpg"||type=="gif"||type=="png"||type=="jpeg"){
					var img = "<img style=\"width:384px;margin-left: -15px;\" src=\"../../../components/gtattachment/open/downloadAttachment.json?attachmentId="
						+ data.data.attachid+"\"/>";
					$("#picCardView").append(img);
				}else if(type=="doc"||type=="docx"||type=="xls"||type=="xlsx"||type=="pdf"){
					var img ="<div class=\"st-docbox\" style=\"height: 141px;\">"+
						"<div class=\"row st-doc\"style=\"width: 392px;\">"+
						"<div class=\"col-md-4 st-doc1\">"+
						"</div>"+
						"<div class=\"col-md-7 st-doc2\">"+
						data.data.attachextname+
						"</div>"+
						"</div>";
					$("#picCardView").append(img);
				}
				$("#shangChuanE").css("pointer-events","none");
				$("#shangChuanE").css("cursor","default");
				
				$("#file").val("");

			},
			error : function(data){// 服务器响应失败处理函数
				console.log("服务器异常");
				$("#file").val("");
			}
		});
	}
	return false;*/
	$("#uploadForm").ajaxSubmit({
    	url: "../../../hivelearn/topic/uploadFileImage.json?_t="+new Date().getTime(),
        data:$("#uploadForm").serialize(),
        dataType:"json",
        success:function(data){
        	$('[name="topicCover"]').val(data.attachid);
			console.log("上传成功");
			
			var type = data.attachextname;
			if(type=="jpg"||type=="gif"||type=="png"||type=="jpeg"){
				$("#picCardView").show();
				var img = "<img style=\"width:390px;margin-left: -15px;\" src=\"../../../components/gtattachment/open/downloadAttachment.json?attachmentId="
					+ data.attachid+"\"/>";
				$('#picCardView').empty();
				$("#picCardView").append(img);
			}else if(type=="doc"||type=="docx"||type=="xls"||type=="xlsx"||type=="pdf"){
//				var img ="<div class=\"st-docbox\" style=\"height: 82px;\">"+
//					"<div class=\"row st-doc\"style=\"width: 392px;\">"+
//					"<div class=\"col-md-4 st-doc1\">"+
//					"</div>"+
//					"<div class=\"col-md-6 st-doc2\" style=\"width: 275px;\">"+
//					data.attachname+
//					"</div>"+
//					"</div>";
				$('#picCardView').empty();
				$('#picCardView2').empty();
//				$("#picCardView").append(img);
				$('#picCardView2').html(type + "附件 上传成功");
			}
			$("#shangChuanE").css("pointer-events","none");
			$("#shangChuanE").css("cursor","default");
			
			$("#file").val("");
		},
		error:function(data){
			console.log("服务器异常");
			$("#file").val("");
		}
    });
}
function yichu(){
	$("#editText").empty();
	$("#picPostView").remove();
	$("#postCover").remove();
	$("#picPostView2").empty();
}
function uploadPostFile(e) {
	/*if ($("#postFile").val()&&checkfileAtt(e)) {
		$.ajax({
			url : "../../../hivelearn/topic/uploadFileImage.json",
			data : new FormData($('#uploadPostForm')[0]),
			method : "post",
			processData : false,
			contentType : false,
			cache : false,
			success : function(data){ // 服务器成功响应处理函数
				$('[name="postCover"]').val(data.data.attachid);
				console.log("上传成功");
				
				$("#picPostView").show();
				var type = data.data.attachextname;
				if(type=="jpg"||type=="gif"||type=="png"||type=="jpeg"){
					var img = "<img style=\"width:455px;margin-left: -15px;\" src=\"../../../components/gtattachment/open/downloadAttachment.json?attachmentId="
						+ data.data.attachid+"\"/>";
					$("#picPostView").append(img);
				}else if(type=="doc"||type=="docx"||type=="xls"||type=="xlsx"||type=="pdf"){
					var img ="<div class=\"st-docbox\" style=\"height: 141px;\">"+
						"<div class=\"row st-doc\"style=\"width: 455px;\">"+
						"<div class=\"col-md-4 st-doc1\">"+
						"</div>"+
						"<div class=\"col-md-7 st-doc2\">"+
						data.data.attachextname+
						"</div>"+
						"</div>";
					$("#picPostView").append(img);
				}
				$("#shangChuanA").css("pointer-events","none");
				$("#shangChuanA").css("cursor","default");
				$("#shangChuanB").css("pointer-events","none");
				$("#shangChuanB").css("cursor","default");
				
				$("#postFile").val("");
				
			},
			error : function(data){// 服务器响应失败处理函数
				console.log("服务器异常");
				$("#postFile").val("");
			}
		});
	}
	return false;*/
	$("#uploadPostForm").ajaxSubmit({
    	url: "../../../hivelearn/topic/uploadFileImage.json?_t="+new Date().getTime(),
        data:$("#uploadPostForm").serialize(),
        dataType:"json",
        success:function(data){
        	$('[name="postCover"]').val(data.attachid);
			console.log("上传成功");
			
			var type = data.attachextname;
			if(type=="jpg"||type=="gif"||type=="png"||type=="jpeg"){
				$("#picPostView").show();
				var img = "<img style=\"width:455px;margin-left: -15px;\" src=\"../../../components/gtattachment/open/downloadAttachment.json?attachmentId="
					+ data.attachid+"\"/>";
				$('#picPostView').empty();
				$("#picPostView").append(img);
			}else if(type=="doc"||type=="docx"||type=="xls"||type=="xlsx"||type=="pdf"){
//				var img ="<div class=\"st-docbox\" style=\"height: 82px;\">"+
//					"<div class=\"row st-doc\"style=\"width: 455px;\">"+
//					"<div class=\"col-md-4 st-doc1\">"+
//					"</div>"+
//					"<div class=\"col-md-7 st-doc2\">"+
//					data.attachname+
//					"</div>"+
//					"</div>";
				$('#picPostView').empty();
				$('#picPostView2').empty();
//				$("#picPostView").append(img);
				$('#picPostView2').html(type + "附件 上传成功");
			}
			$("#shangChuanA").css("pointer-events","none");
			$("#shangChuanA").css("cursor","default");
			$("#shangChuanB").css("pointer-events","none");
			$("#shangChuanB").css("cursor","default");
			
			$("#postFile").val("");
		},
		error:function(data){
			console.log("服务器异常");
			$("#postFile").val("");
		}
    });
}
function uploadPostShowFile(e) {
	/*if ($("#postShowFile").val()&&checkfileAtt(e)) {
		$.ajax({
			url : "../../../hivelearn/topic/uploadFileImage.json",
			data : new FormData($('#uploadPostShowForm')[0]),
			method : "post",
			processData : false,
			contentType : false,
			cache : false,
			success : function(data){ // 服务器成功响应处理函数
				$('[name="postShowCover"]').val(data.data.attachid);
				console.log("上传成功");
				
				$("#picShowPostView").show();
				var type = data.data.attachextname;
				if(type=="jpg"||type=="gif"||type=="png"||type=="jpeg"){
					var img = "<img style=\"width:384px;margin-left: -15px;\" src=\"../../../components/gtattachment/open/downloadAttachment.json?attachmentId="
						+ data.data.attachid+"\"/>";
					$("#picShowPostView").append(img);
				}else if(type=="doc"||type=="docx"||type=="xls"||type=="xlsx"||type=="pdf"){
					var img ="<div class=\"st-docbox\" style=\"height: 141px;\">"+
						"<div class=\"row st-doc\"style=\"width: 384px;\">"+
						"<div class=\"col-md-4 st-doc1\">"+
						"</div>"+
						"<div class=\"col-md-7 st-doc2\">"+
						data.data.attachextname+
						"</div>"+
						"</div>";
					$("#picShowPostView").append(img);
				}
				$("#shangChuanC").css("pointer-events","none");
				$("#shangChuanC").css("cursor","default");
				
				$("#postShowFile").val("");
				
			},
			error : function(data){// 服务器响应失败处理函数
				console.log("服务器异常");
				$("#postShowFile").val("");
			}
		});
	}
	return false;*/
	$("#uploadPostShowForm").ajaxSubmit({
    	url: "../../../hivelearn/topic/uploadFileImage.json?_t="+new Date().getTime(),
        data:$("#uploadPostShowForm").serialize(),
        dataType:"json",
        success:function(data){
        	$('[name="postShowCover"]').val(data.attachid);
			console.log("上传成功");
			
			var type = data.attachextname;
			if(type=="jpg"||type=="gif"||type=="png"||type=="jpeg"){
				$("#picShowPostView").show();
				var img = "<img style=\"width:384px;margin-left: -15px;\" src=\"../../../components/gtattachment/open/downloadAttachment.json?attachmentId="
					+ data.attachid+"\"/>";
				$('#picShowPostView').empty();
				$('#uploadPostShowView').empty();
				$("#picShowPostView").append(img);
			}else if(type=="doc"||type=="docx"||type=="xls"||type=="xlsx"||type=="pdf"){
//				var img ="<div class=\"st-docbox\" style=\"height: 82px;\">"+
//					"<div class=\"row st-docp\"style=\"width: 384px;\">"+
//					"<div class=\"col-md-4 st-docp1\">"+
//					"</div>"+
//					"<div class=\"col-md-7 st-docp2\">"+
//					data.attachname+
//					"</div>"+
//					"</div>";
				$('#picShowPostView').empty();
				$('#uploadPostShowView').empty();
//				$("#picShowPostView").append(img);
				$("#uploadPostShowView").html(type + "附件 上传成功");
			}
			$("#shangChuanC").css("pointer-events","none");
			$("#shangChuanC").css("cursor","default");
			
			$("#postShowFile").val("");
		},
		error:function(data){
			console.log("服务器异常");
			$("#postShowFile").val("");
		}
    });
}
function uploadRePostFile(e) {
	/*if ($("#rePostFile").val()&&checkfileAtt(e)) {
		$.ajax({
			url : "../../../hivelearn/topic/uploadFileImage.json",
			data : new FormData($('#uploadRePostForm')[0]),
			method : "post",
			processData : false,
			contentType : false,
			cache : false,
			success : function(data){ // 服务器成功响应处理函数
				$('[name="RePostCover"]').val(data.data.attachid);
				console.log("上传成功");
				$("#rePostFile").val("");
				
			},
			error : function(data){// 服务器响应失败处理函数
				console.log("服务器异常");
				$("#rePostFile").val("");
			}
		});
	}
	return false;*/
	$("#uploadRePostForm").ajaxSubmit({
    	url: "../../../hivelearn/topic/uploadFileImage.json?_t="+new Date().getTime(),
        data:$("#uploadRePostForm").serialize(),
        dataType:"json",
        success:function(data){
        	$('[name="RePostCover"]').val(data.attachid);
			console.log("上传成功");
			
			var type = data.attachextname;
			if(type=="jpg"||type=="gif"||type=="png"||type=="jpeg"){
				$("#picShowReCardView"+cpId).show();
				var img = "<img style=\"width: 250px;margin-left: -20px;\" src=\"../../../components/gtattachment/open/downloadAttachment.json?attachmentId="
					+ data.attachid+"\"/>";
				$("#picShowReCardView"+cpId).empty();
				$("#picShowReCardView2"+cpId).empty();
				$("#picShowReCardView"+cpId).append(img);
			}else if(type=="doc"||type=="docx"||type=="xls"||type=="xlsx"||type=="pdf"){
//				var img ="<div class=\"st-docbox\" style=\"height: 40px;\">"+
//					"<div class=\"row st-docp\"style=\"width: 250px;margin-left: -20px;height: 81px;\">"+
//					"<div class=\"col-md-4 st-docp1\" style=\"height: 80px;width: 80px;\">"+
//					"</div>"+
//					"<div class=\"col-md-7 st-docp2\" style=\"width: 165px;\">"+
//					data.attachname+
//					"</div>"+
//					"</div>";
				$("#picShowReCardView"+cpId).empty();
				$("#picShowReCardView2"+cpId).empty();
//				$("#picShowReCardView"+cpId).append(img);
				$("#picShowReCardView2"+cpId).html(type + "附件 上传成功");
			}
			$("#shangChuanC").css("pointer-events","none");
			$("#shangChuanC").css("cursor","default");
			
			$("#rePostFile").val("");
		},
		error:function(data){
			console.log("服务器异常");
			$("#rePostFile").val("");
		}
    });
}
function uploadPostRePostFile(e) {
	/*if ($("#postRePostFile").val()&&checkfileAtt(e)) {
		$.ajax({
			url : "../../../hivelearn/topic/uploadFileImage.json",
			data : new FormData($('#uploadPostRePostForm')[0]),
			method : "post",
			processData : false,
			contentType : false,
			cache : false,
			success : function(data){ // 服务器成功响应处理函数
				$('[name="postRePostCover"]').val(data.data.attachid);
				console.log("上传成功");
				
				$("#picShowRePostView").show();
				var type = data.data.attachextname;
				if(type=="jpg"||type=="gif"||type=="png"||type=="jpeg"){
					var img = "<img style=\"width:250px;margin-left: -15px;\" src=\"../../../components/gtattachment/open/downloadAttachment.json?attachmentId="
						+ data.data.attachid+"\"/>";
					$("#picShowRePostView").append(img);
				}else if(type=="doc"||type=="docx"||type=="xls"||type=="xlsx"||type=="pdf"){
					var img ="<div class=\"st-docbox\" style=\"height: 141px;\">"+
						"<div class=\"row st-doc\"style=\"width: 250px;\">"+
						"<div class=\"col-md-4 st-doc1\">"+
						"</div>"+
						"<div class=\"col-md-7 st-doc2\">"+
						data.data.attachextname+
						"</div>"+
						"</div>";
					$("#picShowRePostView").append(img);
				}
				$("#shangChuanD").css("pointer-events","none");
				$("#shangChuanD").css("cursor","default");
				
				$("#postRePostFile").val("");
				
			},
			error : function(data){// 服务器响应失败处理函数
				console.log("服务器异常");
				$("#postRePostFile").val("");
			}
		});
	}
	return false;*/
	$("#uploadPostRePostForm").ajaxSubmit({
    	url: "../../../hivelearn/topic/uploadFileImage.json?_t="+new Date().getTime(),
        data:$("#uploadPostRePostForm").serialize(),
        dataType:"json",
        success:function(data){
        	$('[name="postRePostCover"]').val(data.attachid);
			console.log("上传成功");
			
			var type = data.attachextname;
			if(type=="jpg"||type=="gif"||type=="png"||type=="jpeg"){
				$("#picShowRePostView"+cpId).show();
				var img = "<img style=\"width:250px;margin-left: 43px;\" src=\"../../../components/gtattachment/open/downloadAttachment.json?attachmentId="
					+ data.attachid+"\"/>";
				$("#picShowRePostView"+cpId).empty();
				$("#uploadRePostShowView"+cpId).empty();
				$("#picShowRePostView"+cpId).append(img);
			}else if(type=="doc"||type=="docx"||type=="xls"||type=="xlsx"||type=="pdf"){
//				var img ="<div class=\"st-docbox\" style=\"height: 40px;\">"+
//					"<div class=\"row st-docp\"style=\"width: 250px;margin-left: 95px;height: 81px;\">"+
//					"<div class=\"col-md-4 st-docp1\" style=\"height: 80px;width: 80px;\">"+
//					"</div>"+
//					"<div class=\"col-md-7 st-docp2\" style=\"width: 165px;line-height: 25px;\">"+
//					data.attachname+
//					"</div>"+
//					"</div>";
				$("#picShowRePostView"+cpId).empty();
				$("#uploadRePostShowView"+cpId).empty();
//				$("#picShowRePostView"+cpId).append(img);
				$("#uploadRePostShowView"+cpId).html(type + "附件 上传成功");
			}
			$("#shangChuanD").css("pointer-events","none");
			$("#shangChuanD").css("cursor","default");
			
			$("#postRePostFile").val("");
		},
		error:function(data){
			console.log("服务器异常");
			$("#postRePostFile").val("");
		}
    });
}

//检查
/*function checkfileAtt(target) {
	var isIE = /msie/i.test(navigator.userAgent) && !window.opera; 
	var fileSize = 0;
	var filetypes = [ ".jpg", ".png", ".gif", ".jpeg", ".doc", ".docx", ".xls", ".xlsx", ".pdf"];
	var filepath = target.value;
	var filemaxsize = 1024 * 20;// 20M
	if (filepath) {
		var isnext = false;
		var fileend = filepath.substring(filepath.indexOf("."));
		if (filetypes && filetypes.length > 0) {
			for ( var i = 0; i < filetypes.length; i++) {
				if (filetypes[i] == fileend) {
					isnext = true;
					break;
				}
			}
		}
		if (!isnext) {
			$("#msgModal").find(".msg").text("请选择.png，.jpg，.gif，.jpeg，.doc，.docx，.xls，.xlsx，.pdf文件上传");
			$("#msgModal").modal("show");
			target.value = "";
			return false;
		}
	} else {
		return false;
	}
	if (isIE && !target.files) {
		var filePath = target.value;
		var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
		if (!fileSystem.FileExists(filePath)) {
			$("#msgModal").find(".msg").text("文件不存在，请重新输入！");
			$("#msgModal").modal("show");
			return false;
		}
		var file = fileSystem.GetFile(filePath);
		fileSize = file.Size;
	} else {
		fileSize = target.files[0].size;
	}

	var size = fileSize / 1024;
	if (size > filemaxsize) {
		$("#msgModal").find(".msg").text("文件大小不能大于" + filemaxsize / 1024 + "M！");
		$("#msgModal").modal("show");
		target.value = "";
		return false;
	}
	if (size <= 0) {
		$("#msgModal").find(".msg").text("文件大小不能为0M！");
		$("#msgModal").modal("show");
		target.value = "";
		return false;
	}
	return true;
}*/

//主题页
function meetinglist(){
	window.location.href="../meetingtheme/meetingTheme.html#"+groupId+","+queryOrgId;
}
//人员列表
function peoplelist(){
	window.location.href="../peopleList/peopleList.html#"+groupId+","+queryOrgId;
}

function downloadFile(id){
	window.location.href="../../../components/gtattachment/open/downloadAttachment.do?attachmentId="+id;
}
var word_w = "500px";
var word_h = "700px";
var ppt_w = "500px";
var ppt_h = "300px";
function initSlide(){
	 $(".ck-slide").each(function(){
		if(!$(this).hasClass("ppt")){
				$(this).css("width",word_w);
				$(this).find("img").css("width",word_w);
				$(this).ckSlide({
					dir: 'x'
				});
	           $(this).find(".ck-slide-dir").css("height",word_h);
	           $(this).find(".ck-slide-dir").css("width",word_w);
          }else{
	       	   $(this).css("width",ppt_w);
	       	   $(this).find("img").css("width",ppt_w);
	       	   $(this).ckSlide({
					dir: 'x'
				});
	           $(this).find(".ck-slide-dir").css("height",ppt_h);
	           $(this).find(".ck-slide-dir").css("width",ppt_w);
          }
		});
}
//修改card
function updateCard(cardId){
	$.ajax({
		url:'../../../hivelearn/card/findCard.json?id=' + cardId+'&groupId='+queryGroupId,
		success:function(data){
			if(data.data.topicId){
				window.location.href="../studyTalkEdit/studyTalkEdit.html#"+cardId+","+queryGroupId+","+data.data.topicId+","+queryOrgId;
			}
		}
	});
}

//复制card
function copyCard(id){
	copyCardId = id;
	$("#copyCardModal").find(".right-content-list").show();
	$("#copyCardModal").find(".right-content-edit").hide();
	$("#copyCardModal").find(".topicImg").empty();
	$("#copyCardModal").find(".topicTitle").text("");
	$("#copyCardModal").find(".topicTitle").attr("title","");
	$("#copyCardModal").find(".title").text("复制");
	$("#copyCardModal").find(".right-top").text("你想复制到哪里？");
	$.ajax({
		url:'../../../hivelearn/card/findCard.json?id=' + id
		+ '&groupId=' + groupId,
		success:function(data){
			if(data.data.cardCover){
				var cardCover = "<img src='../../../components/gtattachment/open/downloadAttachment.json?attachmentId="+data.data.cardCover+"'/>"
				$("#copyCardModal").find(".topicImg").append(cardCover);
			}
			copyTitle=data.data.cardTitle;
			$("#copyCardModal").find(".topicTitle").text(data.data.cardTitle);
			$("#copyCardModal").find(".topicTitle").attr("title",data.data.cardTitle);
			cardGroupList(groupId,"");
			$("#copyCardQueryName").unbind("keyup");
			$("#copyCardQueryName").keyup(function(){
				queryGroupName = $(this).val();
				cardGroupList(groupId,"");
			})
			$('#copyCardModal').modal('show');
		}
	})
}
//群组列表查询（card）
function cardGroupList(groupId,noGroupId) {
	$.get('../../../hivelearn/group/findCopyGroupList.json?queryOrgId='+queryOrgId+"&pageSize="+pageSize
			+"&queryGroupName="+queryGroupName+"&queryGroupId="+groupId+"&queryNoGroupId="+noGroupId, function(datas) {
		if (datas.success) {
			var dom;
			dom = _.template($('#shareCardGroupTpl').html());
			
			var count = datas.data.count;
			dom = dom(datas.data);
			$("#cardGrouplist").html(dom);
			//滚动加载
			$("#copyCardModal").find(".right-content-list").find(".right-list").scroll(function () {  
                var $this = $(this),  
                viewH = $(this).height(),//可见高度  
                contentH = $(this).get(0).scrollHeight,//内容高度  
                scrollTop = $(this).scrollTop();//滚动高度  
                //if(contentH - viewH - scrollTop <= 100) { //到达底部100px时,加载新内容  
                if (scrollTop / (contentH - viewH) >= 0.98&&count>pageSize) { //到达底部100px时,加载新内容  
                    //console.log("scrollTop："+scrollTop+",contentH："+contentH+",viewH："+viewH);  
                    pageSize+=5;
                    cardGroupList(groupId,noGroupId);
                }  
            }); 
		}
	})
}
//群组列表查询（card）
function cardTopicList(id,flag) {
	pageSize=8;
	removeflag = flag;
	$.get("../../../hivelearn/topic/findTopicList.json?pageSize="+pageSize
			+"&queryTopicTitle="+queryTopicTitle+"&queryGroupId="+id+"&groupId="+id, function(datas) {
		if (datas.success) {
			var dom;
			dom = _.template($('#cardGroupTpl').html());
			
			if(flag){
				datas.data.topicQuery.moveflag = 1;
				for(var i=0;i<datas.data.topicQuery.resultList.length;i++){
					if(moveTopicId==datas.data.topicQuery.resultList[i].topicId){
						datas.data.topicQuery.resultList[i].flag = 1;//用于移动card时，不能移动到自己下
					}
				}
			}else{
				datas.data.topicQuery.moveflag=0;
			}
			var count = datas.data.topicQuery.count;
			dom = dom(datas.data.topicQuery);
			$("#cardTopicList").html(dom);
			$("#copyCardModal").find(".right-content-list").hide();
			$("#copyCardModal").find(".right-content-edit").show();
			//返回
			$("#copyCardModal").find(".share-btn").find(".arrow").click(function(){
				$("#copyCardModal").find(".right-content-list").show();
				$("#copyCardModal").find(".right-content-edit").hide();
			});
			//滚动加载
			$("#copyCardModal").find(".right-content-edit").find(".right-list").scroll(function () {  
				var $this = $(this),  
				viewH = $(this).height(),//可见高度  
				contentH = $(this).get(0).scrollHeight,//内容高度  
				scrollTop = $(this).scrollTop();//滚动高度  
				//if(contentH - viewH - scrollTop <= 100) { //到达底部100px时,加载新内容  
				if (scrollTop / (contentH - viewH) >= 0.98&&count>pageSize) { //到达底部100px时,加载新内容  
					//console.log("scrollTop："+scrollTop+",contentH："+contentH+",viewH："+viewH);  
					pageSize+=5;
					cardGroupList(id);
				}  
			}); 
		}
	})
}
//保存复制card
function saveCopyCard(id){
	$.ajax({
		url:"../../../hivelearn/card/copyCard.json",
		data:{"cardId":copyCardId,"topicId":id,"groupId":queryGroupId,"cardTitle":copyTitle},
		success:function(data){
			$("#copyCardModal").modal("hide");
			$("#msgModal").find(".msg").text("保存成功");
			$("#msgModal").modal("show");
		}
	})
}

//移动card
function moveOneCard(id){
	  $('#copyCardModal').find(".copy-card").hide();
	  $('#copyCardModal').find(".move-card").show();
	copyCardId = id;
	$("#copyCardModal").find(".right-content-edit").show();
	$("#copyCardModal").find(".right-content-list").hide();
	$("#copyCardModal").find(".topicImg").empty();
	$("#copyCardModal").find(".topicTitle").text("");
	$("#copyCardModal").find(".topicTitle").attr("title","");
	$("#copyCardModal").find(".title").text("移动");
	$("#copyCardModal").find(".right-top").text("你想移动到哪里？");
	$.ajax({
		url:'../../../hivelearn/card/findCard.json?id=' + id
		+ '&groupId=' + groupId,
		success:function(data){
			if(data.data.cardCover){
				var cardCover = "<img src='../../../components/gtattachment/open/downloadAttachment.json?attachmentId="+data.data.cardCover+"'/>"
				$("#copyCardModal").find(".topicImg").append(cardCover);
			}
			moveTopicId = data.data.topicId;
			copyTitle = data.data.cardTitle;
			$("#copyCardModal").find(".topicTitle").text(data.data.cardTitle);
			$("#copyCardModal").find(".topicTitle").attr("title",data.data.cardTitle);
			cardTopicList(groupId,1);
			$("#queryTopicName").unbind("keyup");
			 $("#queryTopicName").keyup(function(){
				 queryTopicTitle = $(this).val();
				cardTopicList(groupId,1);
			})
			$('#copyCardModal').modal('show');
		}
	})
}

//保存复制card
function saveMoveCard(id){
	$.ajax({
		url:"../../../hivelearn/card/moveCard.json",
		data:{"cardId":copyCardId,"topicId":id,"groupId":queryGroupId,"cardTitle":copyTitle},
		success:function(data){
			$("#copyCardModal").modal("hide");
			$("#msgModal").find(".msg").text("移动成功");
			$("#msgModal").modal("show");
		}
	})
}


function deleteOneCard(id){
	delCardId=id;
	$('#delCardModal').modal('show');
}
function delCard(){
	$.ajax({
		url:"../../../hivelearn/card/deleteCardByIds.json",
		data:{"id":delCardId,"groupId":groupId},
		success:function(data){
			if(data.success){
				$("#delCardModal").modal("hide");
				$("#msgModal").find(".msg").text("删除成功");
				$("#msgModal").modal("show");
			}
		}
	})
}
//修改复制，分享标题
function toUpdateTitle(e){
	$(e).hide();
	var $title = $(e).siblings(".topicTitle");
	var title= $title.text();
	$title.empty();
	$title.append("<input type='text' class='updateCopyTitle' maxlength='40' value='"+title+"'/>");
	$title.find(".updateCopyTitle").focus();
	$title.find(".updateCopyTitle").blur(function(){
		var $val = $(this).val();
		if($val){
			copyTitle=$val;
		}
		$title.empty();
		$title.text(copyTitle);
		$(e).show();
	})
}
function toTop(id,isTop){
	$.ajax({
		url:'../../../hivelearn/hivelearnactivity/toTop.json?id=' + id+'&groupId='+groupId+'&isTop='+isTop,
		success:function(data){
			location.reload();
		}
	})
}
//点击检测是否点击的class="ulbtn"的元素
function clickCheck(){
	var val = "";
	if(!!window.ActiveXObject || "ActiveXObject" in window){
		if(event.srcElement){
			val= event.srcElement.className;
		}
	}else {
		if(event.target.classList){
			val = event.target.classList.value;
		}
	}
	return !val||val.indexOf("ulbtn")==-1;
}
